package com.baigt.jvm.classloader;

import com.sun.java.accessibility.util.Translator;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;

/**
 * 类功能描述:
 *          Launcher
 * @author baigt
 * @version V1.0
 * @since 2019-06-28 23:20
 */
public class BeginClassLoader {
    public static void main(String[] args) throws Exception {
        // 类加载器？ 有几种？为啥？
        System.out.println(String.class.getClassLoader());
        System.out.println(Translator.class.getClassLoader());
        System.out.println(BeginClassLoader.class.getClassLoader());
//        System.out.println(ClassLoader.getSystemClassLoader());
//        testResource();
        Class<?> aClass = Thread.currentThread().getContextClassLoader()
            .loadClass("java.security.KeyStore$Builder$FileBuilder$1");
        System.out.println(aClass.getMethods()[0]);
        System.out.println(aClass.getMethods()[1]);
    }


    static void testResource() throws IOException {
        Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources("com/baigt/jvm/classloader/BeginClassLoader.class");
        while (resources.hasMoreElements()) {
            System.out.println(resources.nextElement());
        }
    }
}
